<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.10.0"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>common_util: src/common_util/timeutil.h File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<script type="text/javascript" src="clipboard.js"></script>
<script type="text/javascript" src="cookie.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectalign">
   <div id="projectname">common_util
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.10.0 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li><li class="navelem"><a class="el" href="dir_2961cad218251a7c35c6867350b80887.html">common_util</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#enum-members">Enumerations</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle"><div class="title">timeutil.h File Reference</div></div>
</div><!--header-->
<div class="contents">

<p>Common time utilities.  
<a href="#details">More...</a></p>
<div class="textblock"><code>#include &lt;cstdint&gt;</code><br />
</div>
<p><a href="timeutil_8h_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="enum-members" name="enum-members"></a>
Enumerations</h2></td></tr>
<tr class="memitem:a5123cf2b94c1fabe15fb9ba61231d5f1" id="r_a5123cf2b94c1fabe15fb9ba61231d5f1"><td class="memItemLeft" align="right" valign="top">enum class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a5123cf2b94c1fabe15fb9ba61231d5f1">cutl::timeunit</a> { <a class="el" href="#a5123cf2b94c1fabe15fb9ba61231d5f1a03c7c0ace395d80182db07ae2c30f034">s</a>
, <a class="el" href="#a5123cf2b94c1fabe15fb9ba61231d5f1aee33e909372d935d190f4fcb2a92d542">ms</a>
, <a class="el" href="#a5123cf2b94c1fabe15fb9ba61231d5f1a0b3b97fa66886c5688ee4ae80ec0c3c2">us</a>
 }</td></tr>
<tr class="memdesc:a5123cf2b94c1fabe15fb9ba61231d5f1"><td class="mdescLeft">&#160;</td><td class="mdescRight">Time unit enum.  <a href="#a5123cf2b94c1fabe15fb9ba61231d5f1">More...</a><br /></td></tr>
<tr class="separator:a5123cf2b94c1fabe15fb9ba61231d5f1"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a2a99e9f55412f069169e60623ba1964a" id="r_a2a99e9f55412f069169e60623ba1964a"><td class="memItemLeft" align="right" valign="top">uint64_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a2a99e9f55412f069169e60623ba1964a">cutl::timestamp</a> (<a class="el" href="#a5123cf2b94c1fabe15fb9ba61231d5f1">timeunit</a> unit)</td></tr>
<tr class="memdesc:a2a99e9f55412f069169e60623ba1964a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get current timestamp.  <br /></td></tr>
<tr class="separator:a2a99e9f55412f069169e60623ba1964a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a138f4ea5f89d12e1660b79877e8d5aa8" id="r_a138f4ea5f89d12e1660b79877e8d5aa8"><td class="memItemLeft" align="right" valign="top">uint64_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a138f4ea5f89d12e1660b79877e8d5aa8">cutl::clocktime</a> (<a class="el" href="#a5123cf2b94c1fabe15fb9ba61231d5f1">timeunit</a> unit)</td></tr>
<tr class="memdesc:a138f4ea5f89d12e1660b79877e8d5aa8"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get current clock time for monotone increment time.  <br /></td></tr>
<tr class="separator:a138f4ea5f89d12e1660b79877e8d5aa8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa6801f26864882bbce8e3aa2b3e58d4a" id="r_aa6801f26864882bbce8e3aa2b3e58d4a"><td class="memItemLeft" align="right" valign="top">uint64_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#aa6801f26864882bbce8e3aa2b3e58d4a">cutl::ms2s</a> (uint64_t time)</td></tr>
<tr class="memdesc:aa6801f26864882bbce8e3aa2b3e58d4a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Convert time from milliseconds to seconds.  <br /></td></tr>
<tr class="separator:aa6801f26864882bbce8e3aa2b3e58d4a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae200cc5e60d5eb1a706040cb77af8a61" id="r_ae200cc5e60d5eb1a706040cb77af8a61"><td class="memItemLeft" align="right" valign="top">uint64_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#ae200cc5e60d5eb1a706040cb77af8a61">cutl::us2s</a> (uint64_t time)</td></tr>
<tr class="memdesc:ae200cc5e60d5eb1a706040cb77af8a61"><td class="mdescLeft">&#160;</td><td class="mdescRight">Convert time from microseconds to seconds.  <br /></td></tr>
<tr class="separator:ae200cc5e60d5eb1a706040cb77af8a61"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa22680f091e52ed6709aaa5c71be7da9" id="r_aa22680f091e52ed6709aaa5c71be7da9"><td class="memItemLeft" align="right" valign="top">uint64_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#aa22680f091e52ed6709aaa5c71be7da9">cutl::us2ms</a> (uint64_t time)</td></tr>
<tr class="memdesc:aa22680f091e52ed6709aaa5c71be7da9"><td class="mdescLeft">&#160;</td><td class="mdescRight">Convert time from seconds to milliseconds.  <br /></td></tr>
<tr class="separator:aa22680f091e52ed6709aaa5c71be7da9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8b63bc9d427d2c83faac20de68b143b7" id="r_a8b63bc9d427d2c83faac20de68b143b7"><td class="memItemLeft" align="right" valign="top">uint64_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a8b63bc9d427d2c83faac20de68b143b7">cutl::s2ms</a> (uint64_t time)</td></tr>
<tr class="memdesc:a8b63bc9d427d2c83faac20de68b143b7"><td class="mdescLeft">&#160;</td><td class="mdescRight">Convert time from seconds to microseconds.  <br /></td></tr>
<tr class="separator:a8b63bc9d427d2c83faac20de68b143b7"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af9eb8483ea0d5f2062f6fda8abfbe109" id="r_af9eb8483ea0d5f2062f6fda8abfbe109"><td class="memItemLeft" align="right" valign="top">uint64_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#af9eb8483ea0d5f2062f6fda8abfbe109">cutl::s2us</a> (uint64_t time)</td></tr>
<tr class="memdesc:af9eb8483ea0d5f2062f6fda8abfbe109"><td class="mdescLeft">&#160;</td><td class="mdescRight">Convert time from seconds to microseconds.  <br /></td></tr>
<tr class="separator:af9eb8483ea0d5f2062f6fda8abfbe109"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a4c3160c938fa506c2383a3dc976c3fdc" id="r_a4c3160c938fa506c2383a3dc976c3fdc"><td class="memItemLeft" align="right" valign="top">uint64_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a4c3160c938fa506c2383a3dc976c3fdc">cutl::ms2us</a> (uint64_t time)</td></tr>
<tr class="memdesc:a4c3160c938fa506c2383a3dc976c3fdc"><td class="mdescLeft">&#160;</td><td class="mdescRight">Convert time from milliseconds to microseconds.  <br /></td></tr>
<tr class="separator:a4c3160c938fa506c2383a3dc976c3fdc"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Common time utilities. </p>
<dl class="section copyright"><dt>Copyright</dt><dd>Copyright (c) 2024, Spencer.Luo. All Rights Reserved.</dd></dl>
<p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at </p><pre class="fragment">  http://www.apache.org/licenses/LICENSE-2.0
</pre><p> Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations.</p>
<dl class="section author"><dt>Author</dt><dd>spencer.luo </dd></dl>
<dl class="section date"><dt>Date</dt><dd>2024-05-13 </dd></dl>
</div><h2 class="groupheader">Enumeration Type Documentation</h2>
<a id="a5123cf2b94c1fabe15fb9ba61231d5f1" name="a5123cf2b94c1fabe15fb9ba61231d5f1"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a5123cf2b94c1fabe15fb9ba61231d5f1">&#9670;&#160;</a></span>timeunit</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">enum class <a class="el" href="#a5123cf2b94c1fabe15fb9ba61231d5f1">cutl::timeunit</a></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">strong</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Time unit enum. </p>
<table class="fieldtable">
<tr><th colspan="2">Enumerator</th></tr><tr><td class="fieldname"><a id="a5123cf2b94c1fabe15fb9ba61231d5f1a03c7c0ace395d80182db07ae2c30f034" name="a5123cf2b94c1fabe15fb9ba61231d5f1a03c7c0ace395d80182db07ae2c30f034"></a>s&#160;</td><td class="fielddoc"><p>second </p>
</td></tr>
<tr><td class="fieldname"><a id="a5123cf2b94c1fabe15fb9ba61231d5f1aee33e909372d935d190f4fcb2a92d542" name="a5123cf2b94c1fabe15fb9ba61231d5f1aee33e909372d935d190f4fcb2a92d542"></a>ms&#160;</td><td class="fielddoc"><p>millisecond </p>
</td></tr>
<tr><td class="fieldname"><a id="a5123cf2b94c1fabe15fb9ba61231d5f1a0b3b97fa66886c5688ee4ae80ec0c3c2" name="a5123cf2b94c1fabe15fb9ba61231d5f1a0b3b97fa66886c5688ee4ae80ec0c3c2"></a>us&#160;</td><td class="fielddoc"><p>microsecond </p>
</td></tr>
</table>

</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a id="a138f4ea5f89d12e1660b79877e8d5aa8" name="a138f4ea5f89d12e1660b79877e8d5aa8"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a138f4ea5f89d12e1660b79877e8d5aa8">&#9670;&#160;</a></span>clocktime()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint64_t cutl::clocktime </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="#a5123cf2b94c1fabe15fb9ba61231d5f1">timeunit</a></td>          <td class="paramname"><span class="paramname"><em>unit</em></span></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Get current clock time for monotone increment time. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">unit</td><td>time unit </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>uint64_t clock time </dd></dl>

</div>
</div>
<a id="aa6801f26864882bbce8e3aa2b3e58d4a" name="aa6801f26864882bbce8e3aa2b3e58d4a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa6801f26864882bbce8e3aa2b3e58d4a">&#9670;&#160;</a></span>ms2s()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint64_t cutl::ms2s </td>
          <td>(</td>
          <td class="paramtype">uint64_t</td>          <td class="paramname"><span class="paramname"><em>time</em></span></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Convert time from milliseconds to seconds. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">time</td><td>time in milliseconds </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>uint64_t time in seconds </dd></dl>

</div>
</div>
<a id="a4c3160c938fa506c2383a3dc976c3fdc" name="a4c3160c938fa506c2383a3dc976c3fdc"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a4c3160c938fa506c2383a3dc976c3fdc">&#9670;&#160;</a></span>ms2us()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint64_t cutl::ms2us </td>
          <td>(</td>
          <td class="paramtype">uint64_t</td>          <td class="paramname"><span class="paramname"><em>time</em></span></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Convert time from milliseconds to microseconds. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">time</td><td>time in milliseconds </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>uint64_t time in microseconds </dd></dl>

</div>
</div>
<a id="a8b63bc9d427d2c83faac20de68b143b7" name="a8b63bc9d427d2c83faac20de68b143b7"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a8b63bc9d427d2c83faac20de68b143b7">&#9670;&#160;</a></span>s2ms()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint64_t cutl::s2ms </td>
          <td>(</td>
          <td class="paramtype">uint64_t</td>          <td class="paramname"><span class="paramname"><em>time</em></span></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Convert time from seconds to microseconds. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">time</td><td>time in seconds </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>uint64_t time in microseconds </dd></dl>

</div>
</div>
<a id="af9eb8483ea0d5f2062f6fda8abfbe109" name="af9eb8483ea0d5f2062f6fda8abfbe109"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af9eb8483ea0d5f2062f6fda8abfbe109">&#9670;&#160;</a></span>s2us()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint64_t cutl::s2us </td>
          <td>(</td>
          <td class="paramtype">uint64_t</td>          <td class="paramname"><span class="paramname"><em>time</em></span></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Convert time from seconds to microseconds. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">time</td><td>time in seconds </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>uint64_t time in microseconds </dd></dl>

</div>
</div>
<a id="a2a99e9f55412f069169e60623ba1964a" name="a2a99e9f55412f069169e60623ba1964a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a2a99e9f55412f069169e60623ba1964a">&#9670;&#160;</a></span>timestamp()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint64_t cutl::timestamp </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="#a5123cf2b94c1fabe15fb9ba61231d5f1">timeunit</a></td>          <td class="paramname"><span class="paramname"><em>unit</em></span></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Get current timestamp. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">unit</td><td>time unit </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>uint64_t timestamp </dd></dl>

</div>
</div>
<a id="aa22680f091e52ed6709aaa5c71be7da9" name="aa22680f091e52ed6709aaa5c71be7da9"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa22680f091e52ed6709aaa5c71be7da9">&#9670;&#160;</a></span>us2ms()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint64_t cutl::us2ms </td>
          <td>(</td>
          <td class="paramtype">uint64_t</td>          <td class="paramname"><span class="paramname"><em>time</em></span></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Convert time from seconds to milliseconds. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">time</td><td>time in seconds </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>uint64_t time in milliseconds </dd></dl>

</div>
</div>
<a id="ae200cc5e60d5eb1a706040cb77af8a61" name="ae200cc5e60d5eb1a706040cb77af8a61"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ae200cc5e60d5eb1a706040cb77af8a61">&#9670;&#160;</a></span>us2s()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint64_t cutl::us2s </td>
          <td>(</td>
          <td class="paramtype">uint64_t</td>          <td class="paramname"><span class="paramname"><em>time</em></span></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Convert time from microseconds to seconds. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">time</td><td>time in microseconds </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>uint64_t time in seconds </dd></dl>

</div>
</div>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.10.0
</small></address>
</body>
</html>
